<?php
/**
 * Created by Dumitru Russu
 * User: developer
 * Date: 9/14/12
 * Time: 4:13 PM
 * To change this template use File | Settings | File Templates.
 */
class Page_Be_Products_Designs extends Page {
    /**
     * @var Db_Products_Designs
     */
    protected $tableObject;
    function __construct() {
        $this->idTableObject = get('id', 'int');
        $this->classTableObject = 'Db_Products_Designs';
        $this->actionsTableObject = array(
            'defaultAction',
            'loadDesignsDataAction',
        );
        parent::__construct();
    }

    public function defaultAction() {
        self::$TPL->appendJsFile('admin/designs');
        self::$TPL->setBodyTemplate('list_designs');
        return array(
            'type' => 'display'
        );
    }

	public function loadDesignsDataAction() {
		$allColumns = array('nr', 'd_name', 't_name', 'te_name');
		$searchColumns = array('d_name', 't_name', 'te_name');

        list($searchQuery,$orderBy,$limit) = Utils::getSqlQueriesForPagination($allColumns, $searchColumns, "Db_Products_Designs", "getTotalDesigns");

		$allDesigns = $this->tableObject->getAllDesigns($limit, $searchQuery, $orderBy);
		self::$TPL->assign('allDesigns', $allDesigns);

		return array(
			'type' => 'encoded_json',
			'content' => self::$TPL->display('json_list_designs', true)
		);
	}

}
